<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta charset="UTF-8">
	<title>银行卡</title>
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telephone=no,email=no,adress=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />  
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" href="{THEME_PATH}styles/swiper.min.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/reset.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/common.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/style.css">
	
</head>
<body>
	<!-- S header -->
	<header>
		<a href="/index.php?m=user&c=home&a=wallet_index" class="headerL iconfont">&#xe69f;</a>
		<h1>银行卡</h1>
	</header>
	<!-- E header -->
	
	<ul class="my-centre-item border0 card-infos-wrap">
		<li>
			<a href="javascript:;" class="flex flex-pack-justify">
				<div>
					账号
				</div>
				<div class="right"><?php echo $bank_info['bank_number']; ?></div>
			</a>
		</li>
		<li>
			<a href="javascript:;" class="flex flex-pack-justify">
				<div>
					开户行
				</div>
				<div class="right"><?php echo $bank_info['bank_type']; ?></div>
			</a>
		</li>
		<li>
			<a href="/index.php?m=user&c=home&a=add_bank" class="flex flex-pack-justify">
				<div>
					添加银行卡
				</div>
				<div class="right"><i class="iconfont">&#xe6a0;</i></div>
			</a>
		</li>
		<li>
			<a href="javascript:;" class="flex flex-pack-justify" onclick="payment()">
				<div>
					解除银行卡
				</div>
				<div class="right"><i class="iconfont">&#xe6a0;</i></div>
			</a>
		</li>
	</ul>


	<div class="popup_shade"></div>
	<!-- S 解除绑定弹窗 -->
	<div class="payment_popUp relieve-popUp" id="payment_popUp">
		<div class="flex flex-pack-justify card-wrap">
			<label>储蓄卡</label>
			<div class="numb"><?php echo $bank_info ? $bank_info['bank_type'] : ''; ?>（<?php  echo $bank_info ? substr($bank_info['bank_number'],-4,4) : ''; ?>）</div>
		</div>
		<dl class="money">
			<dt><img src="{THEME_PATH}images/jiechu.png" alt="" width="24" height="24" class="img"></dt>
			<dd>解除绑定银行卡</dd>
		</dl>
		<div class="transaction-password">
			<h3>请输入交易密码</h3>
			<div class="password-wrap flex flex-pack-justify">
				<input type="password" maxlength="1" name="password_1" onkeyup="this.value=this.value.replace(/\D/g,'')">
				<input type="password" maxlength="1" name="password_2" onkeyup="this.value=this.value.replace(/\D/g,'')">
				<input type="password" maxlength="1" name="password_3" onkeyup="this.value=this.value.replace(/\D/g,'')">
				<input type="password" maxlength="1" name="password_4" onkeyup="this.value=this.value.replace(/\D/g,'')">
				<input type="password" maxlength="1" name="password_5" onkeyup="this.value=this.value.replace(/\D/g,'')">
				<input type="password" maxlength="1" name="password_6" onkeyup="this.value=this.value.replace(/\D/g,'')">
			</div>
		</div>
		<a href="javascript:;" class="btn submit_btn">提交</a>
	</div>
	<!-- E 解除绑定弹窗 -->

	<!-- S 解除成功 -->
	<div class="payment_popUp relieve-popUp" id="success">
		<div class="flex flex-pack-justify card-wrap">
			<label>储蓄卡</label>
			<div class="numb"><?php echo $bank_info ? $bank_info['bank_type'] : ''; ?>（<?php  echo $bank_info ? substr($bank_info['bank_number'],-4,4) : ''; ?>）</div>
		</div>
		<dl class="money">
			<dt><img src="{THEME_PATH}images/success.png" alt="" width="30" height="30" class="img"></dt>
			<dd>解除成功</dd>
		</dl>
		<a href="" class="btn">确定</a>
	</div>
	<!-- E 解除成功  -->

	<script src="{THEME_PATH}js/jquery-1.8.3.min.js"></script>
	<script src="{THEME_PATH}js/swiper.min.js"></script>
	<script src="/statics/js/layer/layer.js"></script>
	<script>

		//解除绑定银行卡
		function payment(){
			$(".popup_shade,#payment_popUp").show();
		}
		
		$('.submit_btn').click(function(){
			var bank_info = <?php echo count($bank_info); ?>;
			if(bank_info == 0){
				layer.msg('您没有可解除的银行卡');
				setTimeout(function(){
							location.reload();
						},1000);
				return;
			}
			var bank_id = <?php echo $bank_info ? $bank_info['id'] : 0 ?>;
		
			var password_1 = $("input[ name='password_1' ] ").val();
			var password_2 = $("input[ name='password_2' ] ").val();
			var password_3 = $("input[ name='password_3' ] ").val();
			var password_4 = $("input[ name='password_4' ] ").val();
			var password_5 = $("input[ name='password_5' ] ").val();
			var password_6 = $("input[ name='password_6' ] ").val();
			if(password_1 === ''||password_2 === '' || password_3 === ''|| password_4 === '' || password_5 === '' || password_6 === ''){
				layer.msg('不能为空');
				setTimeout(function(){
							location.reload();
						},1000);
				return;
			}
			var password = password_1+""+password_2+""+password_3+""+password_4+""+password_5+""+password_6;
			$.ajax({
				url:"/index.php/?m=user&c=home&a=remove_bank",
				type:'post',
				data:{password:password,bank_id:bank_id},
				dataType:'json',
				success:function(data){
					if(data.status ==0){
						layer.msg(data.info);
						setTimeout(function(){
							location.reload();
						},1000);
					}else{
						$(".popup_shade,#payment_popUp").hide();
						$(".popup_shade,#success").show();

						
				
						// layer.close(index);
						return;
					}
				}
			});
		})
	</script>
	<script>
		//密码框自动聚焦下一个
		function bindKeyEvent() {
			var password = document.querySelector(".password-wrap");
			password.onkeyup = function (event) {
				event = event || window.event;
				tabForward(event);
			}
		 
			password.onkeydown = function (event) {
				tabBackward(event);
			}
		}
		 
		 
		function tabForward(event) {
			var target = event.target || window.event.srcElement;
			if(target.nextElementSibling && event.keyCode != 8) {
				target.nextElementSibling.focus();
			}
		}
		 
		 
		function tabBackward(event) {
			var target = event.target || window.event.srcElement;
			if(target.previousElementSibling && 
				event.keyCode == 8 &&
				target.value == "") {
				target.previousElementSibling.value = "";
				target.previousElementSibling.focus();
			}
		}
		 
		window.onload = function (event) {
			bindKeyEvent();
		}
	</script>
</body>